<template>
  <div
    ref="box"
    class="littleBox"
    @mouseenter="handleMouseEnter"
    @mouseleave="handleMouseLeave"
  >
    <button ref="btn">
      <span class="title">{{ shownum }}</span>
    </button>
    <h1 class="t2" v-if="!isOpen">
      {{ item.textOne }} <span class="purple">AI</span>
    </h1>
    <div v-if="isOpen" class="text">
      <!-- <span style="font-size: 20px;">认识</span> -->
      <h1>{{ item.textOne }}</h1>
      <h3>{{ item.textTwo }}</h3>
    </div>
    <div v-else class="text">
      <slot name="foot"></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object
    }
  },
  created() {
    this.shownum = '0' + this.item.num
  },
  data() {
    return {
      shownum: '',
      isOpen: true,
      timerId: ''
    }
  },
  methods: {
    handleMouseEnter() {
      this.$refs.btn.style.height = '10px'
      this.$refs.btn.style.top = '0'
      this.$nextTick(() => {
        this.shownum = ''

        if (this.isOpen === true) {
          this.isOpen = false
        }
      })
    },
    handleMouseLeave() {
      this.$refs.btn.style.top = '2rem'
      this.$nextTick(() => {
        this.shownum = '0' + this.item.num
        this.$refs.btn.style.height = '35px'
        if (this.isOpen === false) {
          this.isOpen = true
        }
      })
    }
  }
}
</script>

<style scoped>
.littleBox {
  background-image: url('@/assets/img/home/hometag.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  position: relative;
  width: 11.5rem;
  height: 11.5rem;
  padding: 80px 0 0 32px;
  border-radius: 32px;
  text-align: left;
  box-shadow: 15px 15px 25px 0px rgba(74, 64, 191, 0.2);
  position: relative;
  transition: all 0.4s ease-out;
  cursor: auto;
}

.purple {
  background: linear-gradient(96deg, #694dff 0%, #9c84ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-family: 'AlibabaPuHuiTi2ExtraBold';
  font-style: normal;
  margin-left: 8px;
}

.t2 {
  margin: 0;
  position: absolute;
  top: 1.25rem;
  left: 32px;
}

.text h1 {
  margin-top: 1rem;
  color: #120d2b;
  font-family: AlibabaPuHuiTi2Heavy;
  font-size: 30px;
  font-style: normal;
  line-height: 100%;
  letter-spacing: 2.4px;
}
.text h3 {
  margin-top: 1rem;
  color: #120d2b;
  font-family: 'AlibabaPuHuiTi2';
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 100%;
}

button {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #fff;
  /* background-color: #a176ff; */
  background: linear-gradient(96deg, #694dff 0%, #9c84ff 100%);
  border: 0;
  top: 2rem;
  position: absolute;
  width: 55px;
  height: 36px;
  border-radius: 108px;
  transition: all 0.4s ease-out;
}

.title {
  color: #fff;
  font-family: 'AlibabaPuHuiTi2Heavy';
  font-size: 24px;
  font-style: normal;
  line-height: 120%;
}
</style>
